package com.zw.admin.server.service.impl;

import com.alibaba.fastjson.JSON;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.iot.model.v20180120.*;
import com.zw.admin.server.model.SysChan;
import com.zw.admin.server.service.ChanSerivce;
import com.zw.admin.server.service.SoilSerivce;
import com.zw.admin.server.utils.AbstractManager;
import com.zw.admin.server.utils.LogUtil;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 类描述
 *
 * @author Mr.Wu
 * @create 2019-11-20
 */
@Service
public class SysSoilServiceImpl implements SoilSerivce {

	private static DefaultAcsClient client = AbstractManager.getClient();

	/**
	 * 查询产品列表
	 *
	 * @param currentPage         指定从返回结果中的第几页开始显示  非必需
	 * @param pageSize            指定返回结果中每页显示的记录数量，最大值是200 非必需
	 * @param aliyunCommodityCode 产品描述 非必需 是
	 */
	@Override
	public QueryProductListResponse.Data QueryProductList(Integer currentPage, Integer pageSize, String aliyunCommodityCode) {

		QueryProductListResponse response = null;
		QueryProductListRequest request = new QueryProductListRequest();

		request.setAliyunCommodityCode(aliyunCommodityCode);
		request.setPageSize(pageSize);
		request.setCurrentPage(currentPage);

		try {
			response = client.getAcsResponse(request);

			if (response.getSuccess() != null && response.getSuccess()) {
				LogUtil.print("查询产品列表");
				LogUtil.print(JSON.toJSONString(response));
			} else {
				LogUtil.print("查询产品列表失败");
				LogUtil.error(JSON.toJSONString(response));
			}
			return response.getData();

		} catch (ClientException e) {
			e.printStackTrace();
			LogUtil.error("查询产品列表失败！" + JSON.toJSONString(response));
		}
		return null;
	}



}
